home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / emacssrc.zip / EMACSSRC.TAR / emacs-19.17 / src / data.c < prev    next >
C/C++ Source or Header  |  1993-10-15  |  66KB  |  2,295 lines

  1. /* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter.
  2.    Copyright (C) 1985, 1986, 1988, 1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. #include <signal.h>
  22.  
  23. #include "config.h"
  24. #include "lisp.h"
  25. #include "puresize.h"
  26.  
  27. #ifndef standalone
  28. #include "buffer.h"
  29. #endif
  30.  
  31. #include "syssignal.h"
  32.  
  33. #ifdef LISP_FLOAT_TYPE
  34. #ifdef STDC_HEADERS
  35. #include <stdlib.h>
  36. #endif
  37. #include <math.h>
  38. #endif /* LISP_FLOAT_TYPE */
  39.  
  40. #ifdef STDC_HEADERS
  41. #include <stdio.h>
  42. #endif
  43. #ifdef WINDOWSNT
  44. #include "ntproc_p.h"
  45. #endif
  46. #include "data_p.h"
  47. static Lisp_Object swap_in_symval_forwarding _P_((Lisp_Object sym,
  48.                                                   Lisp_Object valcontents));
  49.  
  50. Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound;
  51. Lisp_Object Qerror_conditions, Qerror_message, Qtop_level;
  52. Lisp_Object Qerror, Qquit, Qwrong_type_argument, Qargs_out_of_range;
  53. Lisp_Object Qvoid_variable, Qvoid_function, Qcyclic_function_indirection;
  54. Lisp_Object Qsetting_constant, Qinvalid_read_syntax;
  55. Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch;
  56. Lisp_Object Qend_of_file, Qarith_error, Qmark_inactive;
  57. Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only;
  58. Lisp_Object Qintegerp, Qnatnump, Qsymbolp, Qlistp, Qconsp;
  59. Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp;
  60. Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp;
  61. Lisp_Object Qbuffer_or_string_p;
  62. Lisp_Object Qboundp, Qfboundp;
  63. Lisp_Object Qcdr;
  64.  
  65. Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error;
  66. Lisp_Object Qoverflow_error, Qunderflow_error;
  67.  
  68. #ifdef LISP_FLOAT_TYPE
  69. Lisp_Object Qfloatp;
  70. Lisp_Object Qnumberp, Qnumber_or_marker_p;
  71. #endif
  72.  
  73. Lisp_Object
  74. wrong_type_argument (predicate, value)
  75.      register Lisp_Object predicate, value;
  76. {
  77.   register Lisp_Object tem;
  78.   do
  79.     {
  80.       if (!EQ (Vmocklisp_arguments, Qt))
  81.     {
  82.      if (XTYPE (value) == Lisp_String &&
  83.          (EQ (predicate, Qintegerp) || EQ (predicate, Qinteger_or_marker_p)))
  84.        return Fstring_to_number (value);
  85.      if (XTYPE (value) == Lisp_Int && EQ (predicate, Qstringp))
  86.        return Fnumber_to_string (value);
  87.     }
  88.       value = Fsignal (Qwrong_type_argument, Fcons (predicate, Fcons (value, Qnil)));
  89.       tem = call1 (predicate, value);
  90.     }
  91.   while (NILP (tem));
  92.   return value;
  93. }
  94.  
  95. _VOID_
  96. pure_write_error ()
  97. {
  98.   error ("Attempt to modify read-only object");
  99. }
  100.  
  101. void
  102. args_out_of_range (a1, a2)
  103.      Lisp_Object a1, a2;
  104. {
  105.   while (1)
  106.     Fsignal (Qargs_out_of_range, Fcons (a1, Fcons (a2, Qnil)));
  107. }
  108.  
  109. void
  110. args_out_of_range_3 (a1, a2, a3)
  111.      Lisp_Object a1, a2, a3;
  112. {
  113.   while (1)
  114.     Fsignal (Qargs_out_of_range, Fcons (a1, Fcons (a2, Fcons (a3, Qnil))));
  115. }
  116.  
  117. Lisp_Object
  118. make_number (num)
  119.      int num;
  120. {
  121.   register Lisp_Object val;
  122.   XSET (val, Lisp_Int, num);
  123.   return val;
  124. }
  125.  
  126. /* On some machines, XINT needs a temporary location.
  127.    Here it is, in case it is needed.  */
  128.  
  129. int sign_extend_temp;
  130.  
  131. /* On a few machines, XINT can only be done by calling this.  */
  132.  
  133. int
  134. sign_extend_lisp_int (num)
  135.      int num;
  136. {
  137.   if (num & (1 << (VALBITS - 1)))
  138.     return num | ((-1) << VALBITS);
  139.   else
  140.     return num & ((1 << VALBITS) - 1);
  141. }
  142.  
  143. /* Data type predicates */
  144.  
  145. DEFUN ("eq", Feq, Seq, 2, 2, 0,
  146.   "T if the two args are the same Lisp object.")
  147.   (obj1, obj2)
  148.      Lisp_Object obj1, obj2;
  149. {
  150.   if (EQ (obj1, obj2))
  151.     return Qt;
  152.   return Qnil;
  153. }
  154.  
  155. DEFUN ("null", Fnull, Snull, 1, 1, 0, "T if OBJECT is nil.")
  156.   (obj)
  157.      Lisp_Object obj;
  158. {
  159.   if (NILP (obj))
  160.     return Qt;
  161.   return Qnil;
  162. }
  163.  
  164. DEFUN ("consp", Fconsp, Sconsp, 1, 1, 0, "T if OBJECT is a cons cell.")
  165.   (obj)
  166.      Lisp_Object obj;
  167. {
  168.   if (XTYPE (obj) == Lisp_Cons)
  169.     return Qt;
  170.   return Qnil;
  171. }
  172.  
  173. DEFUN ("atom", Fatom, Satom, 1, 1, 0, "T if OBJECT is not a cons cell.  This includes nil.")
  174.   (obj)
  175.      Lisp_Object obj;
  176. {
  177.   if (XTYPE (obj) == Lisp_Cons)
  178.     return Qnil;
  179.   return Qt;
  180. }
  181.  
  182. DEFUN ("listp", Flistp, Slistp, 1, 1, 0, "T if OBJECT is a list.  This includes nil.")
  183.   (obj)
  184.      Lisp_Object obj;
  185. {
  186.   if (XTYPE (obj) == Lisp_Cons || NILP (obj))
  187.     return Qt;
  188.   return Qnil;
  189. }
  190.  
  191. DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, "T if OBJECT is not a list.  Lists include nil.")
  192.   (obj)
  193.      Lisp_Object obj;
  194. {
  195.   if (XTYPE (obj) == Lisp_Cons || NILP (obj))
  196.     return Qnil;
  197.   return Qt;
  198. }
  199.  
  200. DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, "T if OBJECT is a symbol.")
  201.   (obj)
  202.      Lisp_Object obj;
  203. {
  204.   if (XTYPE (obj) == Lisp_Symbol)
  205.     return Qt;
  206.   return Qnil;
  207. }
  208.  
  209. DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, "T if OBJECT is a vector.")
  210.   (obj)
  211.      Lisp_Object obj;
  212. {
  213.   if (XTYPE (obj) == Lisp_Vector)
  214.     return Qt;
  215.   return Qnil;
  216. }
  217.  
  218. DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, "T if OBJECT is a string.")
  219.   (obj)
  220.      Lisp_Object obj;
  221. {
  222.   if (XTYPE (obj) == Lisp_String)
  223.     return Qt;
  224.   return Qnil;
  225. }
  226.  
  227. DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0, "T if OBJECT is an array (string or vector).")
  228.   (obj)
  229.      Lisp_Object obj;
  230. {
  231.   if (XTYPE (obj) == Lisp_Vector || XTYPE (obj) == Lisp_String)
  232.     return Qt;
  233.   return Qnil;
  234. }
  235.  
  236. DEFUN ("sequencep", Fsequencep, Ssequencep, 1, 1, 0,
  237.   "T if OBJECT is a sequence (list or array).")
  238.   (obj)
  239.      register Lisp_Object obj;
  240. {
  241.   if (CONSP (obj) || NILP (obj) ||
  242.       XTYPE (obj) == Lisp_Vector || XTYPE (obj) == Lisp_String)
  243.     return Qt;
  244.   return Qnil;
  245. }
  246.  
  247. DEFUN ("bufferp", Fbufferp, Sbufferp, 1, 1, 0, "T if OBJECT is an editor buffer.")
  248.   (obj)
  249.      Lisp_Object obj;
  250. {
  251.   if (XTYPE (obj) == Lisp_Buffer)
  252.     return Qt;
  253.   return Qnil;
  254. }
  255.  
  256. DEFUN ("markerp", Fmarkerp, Smarkerp, 1, 1, 0, "T if OBJECT is a marker (editor pointer).")
  257.   (obj)
  258.      Lisp_Object obj;
  259. {
  260.   if (XTYPE (obj) == Lisp_Marker)
  261.     return Qt;
  262.   return Qnil;
  263. }
  264.  
  265. DEFUN ("subrp", Fsubrp, Ssubrp, 1, 1, 0, "T if OBJECT is a built-in function.")
  266.   (obj)
  267.      Lisp_Object obj;
  268. {
  269.   if (XTYPE (obj) == Lisp_Subr)
  270.     return Qt;
  271.   return Qnil;
  272. }
  273.  
  274. DEFUN ("byte-code-function-p", Fbyte_code_function_p, Sbyte_code_function_p,
  275.        1, 1, 0, "T if OBJECT is a byte-compiled function object.")
  276.   (obj)
  277.      Lisp_Object obj;
  278. {
  279.   if (XTYPE (obj) == Lisp_Compiled)
  280.     return Qt;
  281.   return Qnil;
  282. }
  283.  
  284. DEFUN ("char-or-string-p", Fchar_or_string_p, Schar_or_string_p, 1, 1, 0, "T if OBJECT is a character (a number) or a string.")
  285.   (obj)
  286.      register Lisp_Object obj;
  287. {
  288.   if (XTYPE (obj) == Lisp_Int || XTYPE (obj) == Lisp_String)
  289.     return Qt;
  290.   return Qnil;
  291. }
  292.  
  293. DEFUN ("integerp", Fintegerp, Sintegerp, 1, 1, 0, "T if OBJECT is a number.")
  294.   (obj)
  295.      Lisp_Object obj;
  296. {
  297.   if (XTYPE (obj) == Lisp_Int)
  298.     return Qt;
  299.   return Qnil;
  300. }
  301.  
  302. DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1, 0,
  303.   "T if OBJECT is an integer or a marker (editor pointer).")
  304.   (obj)
  305.      register Lisp_Object obj;
  306. {
  307.   if (XTYPE (obj) == Lisp_Marker || XTYPE (obj) == Lisp_Int)
  308.     return Qt;
  309.   return Qnil;
  310. }
  311.  
  312. DEFUN ("natnump", Fnatnump, Snatnump, 1, 1, 0, "T if OBJECT is a nonnegative number.")
  313.   (obj)
  314.      Lisp_Object obj;
  315. {
  316.   if (XTYPE (obj) == Lisp_Int && XINT (obj) >= 0)
  317.     return Qt;
  318.   return Qnil;
  319. }
  320.  
  321. DEFUN ("numberp", Fnumberp, Snumberp, 1, 1, 0,
  322.        "T if OBJECT is a number (floating point or integer).")
  323.   (obj)
  324.      Lisp_Object obj;
  325. {
  326.   if (NUMBERP (obj))
  327.     return Qt;
  328.   else
  329.     return Qnil;
  330. }
  331.  
  332. DEFUN ("number-or-marker-p", Fnumber_or_marker_p,
  333.        Snumber_or_marker_p, 1, 1, 0,
  334.        "T if OBJECT is a number or a marker.")
  335.   (obj)
  336.      Lisp_Object obj;
  337. {
  338.   if (NUMBERP (obj)
  339.       || XTYPE (obj) == Lisp_Marker)
  340.     return Qt;
  341.   return Qnil;
  342. }
  343.  
  344. #ifdef LISP_FLOAT_TYPE
  345. DEFUN ("floatp", Ffloatp, Sfloatp, 1, 1, 0,
  346.        "T if OBJECT is a floating point number.")
  347.   (obj)
  348.      Lisp_Object obj;
  349. {
  350.   if (XTYPE (obj) == Lisp_Float)
  351.     return Qt;
  352.   return Qnil;
  353. }
  354. #endif /* LISP_FLOAT_TYPE */
  355.  
  356. /* Extract and set components of lists */
  357.  
  358. DEFUN ("car", Fcar, Scar, 1, 1, 0,
  359.   "Return the car of CONSCELL.  If arg is nil, return nil.\n\
  360. Error if arg is not nil and not a cons cell.  See also `car-safe'.")
  361.   (list)
  362.      register Lisp_Object list;
  363. {
  364.   while (1)
  365.     {
  366.       if (XTYPE (list) == Lisp_Cons)
  367.     return XCONS (list)->car;
  368.       else if (EQ (list, Qnil))
  369.     return Qnil;
  370.       else
  371.     list = wrong_type_argument (Qlistp, list);
  372.     }
  373. }
  374.  
  375. DEFUN ("car-safe", Fcar_safe, Scar_safe, 1, 1, 0,
  376.   "Return the car of OBJECT if it is a cons cell, or else nil.")
  377.   (object)
  378.      Lisp_Object object;
  379. {
  380.   if (XTYPE (object) == Lisp_Cons)
  381.     return XCONS (object)->car;
  382.   else
  383.     return Qnil;
  384. }
  385.  
  386. DEFUN ("cdr", Fcdr, Scdr, 1, 1, 0,
  387.   "Return the cdr of CONSCELL.  If arg is nil, return nil.\n\
  388. Error if arg is not nil and not a cons cell.  See also `cdr-safe'.")
  389.  
  390.   (list)
  391.      register Lisp_Object list;
  392. {
  393.   while (1)
  394.     {
  395.       if (XTYPE (list) == Lisp_Cons)
  396.     return XCONS (list)->cdr;
  397.       else if (EQ (list, Qnil))
  398.     return Qnil;
  399.       else
  400.     list = wrong_type_argument (Qlistp, list);
  401.     }
  402. }
  403.  
  404. DEFUN ("cdr-safe", Fcdr_safe, Scdr_safe, 1, 1, 0,
  405.   "Return the cdr of OBJECT if it is a cons cell, or else  nil.")
  406.   (object)
  407.      Lisp_Object object;
  408. {
  409.   if (XTYPE (object) == Lisp_Cons)
  410.     return XCONS (object)->cdr;
  411.   else
  412.     return Qnil;
  413. }
  414.  
  415. DEFUN ("setcar", Fsetcar, Ssetcar, 2, 2, 0,
  416.   "Set the car of CONSCELL to be NEWCAR.  Returns NEWCAR.")
  417.   (cell, newcar)
  418.      register Lisp_Object cell, newcar;
  419. {
  420.   if (XTYPE (cell) != Lisp_Cons)
  421.     cell = wrong_type_argument (Qconsp, cell);
  422.  
  423.   CHECK_IMPURE (cell);
  424.   XCONS (cell)->car = newcar;
  425.   return newcar;
  426. }
  427.  
  428. DEFUN ("setcdr", Fsetcdr, Ssetcdr, 2, 2, 0,
  429.   "Set the cdr of CONSCELL to be NEWCDR.  Returns NEWCDR.")
  430.   (cell, newcdr)
  431.      register Lisp_Object cell, newcdr;
  432. {
  433.   if (XTYPE (cell) != Lisp_Cons)
  434.     cell = wrong_type_argument (Qconsp, cell);
  435.  
  436.   CHECK_IMPURE (cell);
  437.   XCONS (cell)->cdr = newcdr;
  438.   return newcdr;
  439. }
  440.  
  441. /* Extract and set components of symbols */
  442.  
  443. DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0, "T if SYMBOL's value is not void.")
  444.   (sym)
  445.      register Lisp_Object sym;
  446. {
  447.   Lisp_Object valcontents;
  448.   CHECK_SYMBOL (sym, 0);
  449.  
  450.   valcontents = XSYMBOL (sym)->value;
  451.  
  452. #ifdef SWITCH_ENUM_BUG
  453.   switch ((int) XTYPE (valcontents))
  454. #else
  455.   switch (XTYPE (valcontents))
  456. #endif
  457.     {
  458.     case Lisp_Buffer_Local_Value:
  459.     case Lisp_Some_Buffer_Local_Value:
  460.       valcontents = swap_in_symval_forwarding (sym, valcontents);
  461.     }
  462.  
  463.   return (XTYPE (valcontents) == Lisp_Void || EQ (valcontents, Qunbound)
  464.       ? Qnil : Qt);
  465. }
  466.  
  467. DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0, "T if SYMBOL's function definition is not void.")
  468.   (sym)
  469.      register Lisp_Object sym;
  470. {
  471.   CHECK_SYMBOL (sym, 0);
  472.   return (XTYPE (XSYMBOL (sym)->function) == Lisp_Void
  473.       || EQ (XSYMBOL (sym)->function, Qunbound))
  474.      ? Qnil : Qt;
  475. }
  476.  
  477. DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0, "Make SYMBOL's value be void.")
  478.   (sym)
  479.      register Lisp_Object sym;
  480. {
  481.   CHECK_SYMBOL (sym, 0);
  482.   if (NILP (sym) || EQ (sym, Qt))
  483.     return Fsignal (Qsetting_constant, Fcons (sym, Qnil));
  484.   Fset (sym, Qunbound);
  485.   return sym;
  486. }
  487.  
  488. DEFUN ("fmakunbound", Ffmakunbound, Sfmakunbound, 1, 1, 0, "Make SYMBOL's function definition be void.")
  489.   (sym)
  490.      register Lisp_Object sym;
  491. {
  492.   CHECK_SYMBOL (sym, 0);
  493.   XSYMBOL (sym)->function = Qunbound;
  494.   return sym;
  495. }
  496.  
  497. DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0,
  498.   "Return SYMBOL's function definition.  Error if that is void.")
  499.   (symbol)
  500.      register Lisp_Object symbol;
  501. {
  502.   CHECK_SYMBOL (symbol, 0);
  503.   if (EQ (XSYMBOL (symbol)->function, Qunbound))
  504.     return Fsignal (Qvoid_function, Fcons (symbol, Qnil));
  505.   return XSYMBOL (symbol)->function;
  506. }
  507.  
  508. DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0, "Return SYMBOL's property list.")
  509.   (sym)
  510.      register Lisp_Object sym;
  511. {
  512.   CHECK_SYMBOL (sym, 0);
  513.   return XSYMBOL (sym)->plist;
  514. }
  515.  
  516. DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0, "Return SYMBOL's name, a string.")
  517.   (sym)
  518.      register Lisp_Object sym;
  519. {
  520.   register Lisp_Object name;
  521.  
  522.   CHECK_SYMBOL (sym, 0);
  523.   XSET (name, Lisp_String, XSYMBOL (sym)->name);
  524.   return name;
  525. }
  526.  
  527. DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
  528.   "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.")
  529.   (sym, newdef)
  530.      register Lisp_Object sym, newdef;
  531. {
  532.   CHECK_SYMBOL (sym, 0);
  533.  
  534.   if (!NILP (Vautoload_queue) && !EQ (XSYMBOL (sym)->function, Qunbound))
  535.     Vautoload_queue = Fcons (Fcons (sym, XSYMBOL (sym)->function),
  536.                  Vautoload_queue);
  537.   XSYMBOL (sym)->function = newdef;
  538.   return newdef;
  539. }
  540.  
  541. /* This name should be removed once it is eliminated from elsewhere.  */
  542.  
  543. DEFUN ("defalias", Fdefalias, Sdefalias, 2, 2, 0,
  544.   "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.\n\
  545. Associates the function with the current load file, if any.")
  546.   (sym, newdef)
  547.      register Lisp_Object sym, newdef;
  548. {
  549.   CHECK_SYMBOL (sym, 0);
  550.   if (!NILP (Vautoload_queue) && !EQ (XSYMBOL (sym)->function, Qunbound))
  551.     Vautoload_queue = Fcons (Fcons (sym, XSYMBOL (sym)->function),
  552.                  Vautoload_queue);
  553.   XSYMBOL (sym)->function = newdef;
  554.   LOADHIST_ATTACH (sym);
  555.   return newdef;
  556. }
  557.  
  558. DEFUN ("define-function", Fdefine_function, Sdefine_function, 2, 2, 0,
  559.   "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.\n\
  560. Associates the function with the current load file, if any.")
  561.   (sym, newdef)
  562.      register Lisp_Object sym, newdef;
  563. {
  564.   CHECK_SYMBOL (sym, 0);
  565.   if (!NILP (Vautoload_queue) && !EQ (XSYMBOL (sym)->function, Qunbound))
  566.     Vautoload_queue = Fcons (Fcons (sym, XSYMBOL (sym)->function),
  567.                  Vautoload_queue);
  568.   XSYMBOL (sym)->function = newdef;
  569.   LOADHIST_ATTACH (sym);
  570.   return newdef;
  571. }
  572.  
  573. DEFUN ("setplist", Fsetplist, Ssetplist, 2, 2, 0,
  574.   "Set SYMBOL's property list to NEWVAL, and return NEWVAL.")
  575.   (sym, newplist)
  576.      register Lisp_Object sym, newplist;
  577. {
  578.   CHECK_SYMBOL (sym, 0);
  579.   XSYMBOL (sym)->plist = newplist;
  580.   return newplist;
  581. }
  582.  
  583.  
  584. /* Getting and setting values of symbols */
  585.  
  586. /* Given the raw contents of a symbol value cell,
  587.    return the Lisp value of the symbol.
  588.    This does not handle buffer-local variables; use
  589.    swap_in_symval_forwarding for that.  */
  590.  
  591. Lisp_Object
  592. do_symval_forwarding (valcontents)
  593.      register Lisp_Object valcontents;
  594. {
  595.   register Lisp_Object val;
  596. #ifdef SWITCH_ENUM_BUG
  597.   switch ((int) XTYPE (valcontents))
  598. #else
  599.   switch (XTYPE (valcontents))
  600. #endif
  601.     {
  602.     case Lisp_Intfwd:
  603.       XSET (val, Lisp_Int, *XINTPTR (valcontents));
  604.       return val;
  605.  
  606.     case Lisp_Boolfwd:
  607.       if (*XINTPTR (valcontents))
  608.     return Qt;
  609.       return Qnil;
  610.  
  611.     case Lisp_Objfwd:
  612.       return *XOBJFWD (valcontents);
  613.  
  614.     case Lisp_Buffer_Objfwd:
  615.       return *(Lisp_Object *)(XUINT (valcontents) + (char *)current_buffer);
  616.     }
  617.   return valcontents;
  618. }
  619.  
  620. /* Store NEWVAL into SYM, where VALCONTENTS is found in the value cell
  621.    of SYM.  If SYM is buffer-local, VALCONTENTS should be the
  622.    buffer-independent contents of the value cell: forwarded just one
  623.    step past the buffer-localness.  */
  624.  
  625. void
  626. store_symval_forwarding (sym, valcontents, newval)
  627.      Lisp_Object sym;
  628.      register Lisp_Object valcontents, newval;
  629. {
  630. #ifdef SWITCH_ENUM_BUG
  631.   switch ((int) XTYPE (valcontents))
  632. #else
  633.   switch (XTYPE (valcontents))
  634. #endif
  635.     {
  636.     case Lisp_Intfwd:
  637.       CHECK_NUMBER (newval, 1);
  638.       *XINTPTR (valcontents) = XINT (newval);
  639.       break;
  640.  
  641.     case Lisp_Boolfwd:
  642.       *XINTPTR (valcontents) = NILP(newval) ? 0 : 1;
  643.       break;
  644.  
  645.     case Lisp_Objfwd:
  646.       *XOBJFWD (valcontents) = newval;
  647.       break;
  648.  
  649.     case Lisp_Buffer_Objfwd:
  650.       {
  651.     unsigned int offset = XUINT (valcontents);
  652.     Lisp_Object type =
  653.       *(Lisp_Object *)(offset + (char *)&buffer_local_types);
  654.  
  655.     if (! NILP (type) && ! NILP (newval)
  656.         && XTYPE (newval) != XINT (type))
  657.       buffer_slot_type_mismatch (valcontents, newval);
  658.     
  659.     *(Lisp_Object *)(XUINT (valcontents) + (char *)current_buffer)
  660.       = newval;
  661.     break;
  662.       }
  663.  
  664.     default:
  665.       valcontents = XSYMBOL (sym)->value;
  666.       if (XTYPE (valcontents) == Lisp_Buffer_Local_Value
  667.       || XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value)
  668.     XCONS (XSYMBOL (sym)->value)->car = newval;
  669.       else
  670.     XSYMBOL (sym)->value = newval;
  671.     }
  672. }
  673.  
  674. /* Set up the buffer-local symbol SYM for validity in the current
  675.    buffer.  VALCONTENTS is the contents of its value cell.
  676.    Return the value forwarded one step past the buffer-local indicator.  */
  677.  
  678. static Lisp_Object
  679. swap_in_symval_forwarding (sym, valcontents)
  680.      Lisp_Object sym, valcontents;
  681. {
  682.   /* valcontents is a list
  683.      (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE)).
  684.      
  685.      CURRENT-ALIST-ELEMENT is a pointer to an element of BUFFER's
  686.      local_var_alist, that being the element whose car is this
  687.      variable.  Or it can be a pointer to the
  688.      (CURRENT-ALIST-ELEMENT . DEFAULT-VALUE), if BUFFER does not have
  689.      an element in its alist for this variable.
  690.  
  691.      If the current buffer is not BUFFER, we store the current
  692.      REALVALUE value into CURRENT-ALIST-ELEMENT, then find the
  693.      appropriate alist element for the buffer now current and set up
  694.      CURRENT-ALIST-ELEMENT.  Then we set REALVALUE out of that
  695.      element, and store into BUFFER.
  696.  
  697.      Note that REALVALUE can be a forwarding pointer. */
  698.  
  699.   register Lisp_Object tem1;
  700.   tem1 = XCONS (XCONS (valcontents)->cdr)->car;
  701.  
  702.   if (NILP (tem1) || current_buffer != XBUFFER (tem1))
  703.     {
  704.       tem1 = XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car;
  705.       Fsetcdr (tem1, do_symval_forwarding (XCONS (valcontents)->car));
  706.       tem1 = assq_no_quit (sym, current_buffer->local_var_alist);
  707.       if (NILP (tem1))
  708.     tem1 = XCONS (XCONS (valcontents)->cdr)->cdr;
  709.       XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car = tem1;
  710.       XSET (XCONS (XCONS (valcontents)->cdr)->car, Lisp_Buffer, current_buffer);
  711.       store_symval_forwarding (sym, XCONS (valcontents)->car, Fcdr (tem1));
  712.     }
  713.   return XCONS (valcontents)->car;
  714. }
  715.  
  716. /* Find the value of a symbol, returning Qunbound if it's not bound.
  717.    This is helpful for code which just wants to get a variable's value
  718.    if it has one, without signalling an error.
  719.    Note that it must not be possible to quit
  720.    within this function.  Great care is required for this.  */
  721.  
  722. Lisp_Object
  723. find_symbol_value (sym)
  724.      Lisp_Object sym;
  725. {
  726.   register Lisp_Object valcontents;
  727.   register Lisp_Object val;
  728.   CHECK_SYMBOL (sym, 0);
  729.   valcontents = XSYMBOL (sym)->value;
  730.  
  731.  retry:
  732. #ifdef SWITCH_ENUM_BUG
  733.   switch ((int) XTYPE (valcontents))
  734. #else
  735.   switch (XTYPE (valcontents))
  736. #endif
  737.     {
  738.     case Lisp_Buffer_Local_Value:
  739.     case Lisp_Some_Buffer_Local_Value:
  740.       valcontents = swap_in_symval_forwarding (sym, valcontents);
  741.       goto retry;
  742.  
  743.     case Lisp_Intfwd:
  744.       XSET (val, Lisp_Int, *XINTPTR (valcontents));
  745.       return val;
  746.  
  747.     case Lisp_Boolfwd:
  748.       if (*XINTPTR (valcontents))
  749.     return Qt;
  750.       return Qnil;
  751.  
  752.     case Lisp_Objfwd:
  753.       return *XOBJFWD (valcontents);
  754.  
  755.     case Lisp_Buffer_Objfwd:
  756.       return *(Lisp_Object *)(XUINT (valcontents) + (char *)current_buffer);
  757.  
  758.     case Lisp_Void:
  759.       return Qunbound;
  760.     }
  761.  
  762.   return valcontents;
  763. }
  764.  
  765. DEFUN ("symbol-value", Fsymbol_value, Ssymbol_value, 1, 1, 0,
  766.   "Return SYMBOL's value.  Error if that is void.")
  767.   (sym)
  768.      Lisp_Object sym;
  769. {
  770.   Lisp_Object val = find_symbol_value (sym);
  771.  
  772.   if (EQ (val, Qunbound))
  773.     return Fsignal (Qvoid_variable, Fcons (sym, Qnil));
  774.   else
  775.     return val;
  776. }
  777.  
  778. DEFUN ("set", Fset, Sset, 2, 2, 0,
  779.   "Set SYMBOL's value to NEWVAL, and return NEWVAL.")
  780.   (sym, newval)
  781.      register Lisp_Object sym, newval;
  782. {
  783.   int voide = (XTYPE (newval) == Lisp_Void || EQ (newval, Qunbound));
  784.  
  785. #ifndef RTPC_REGISTER_BUG
  786.   register Lisp_Object valcontents, tem1, current_alist_element;
  787. #else /* RTPC_REGISTER_BUG */
  788.   register Lisp_Object tem1;
  789.   Lisp_Object valcontents, current_alist_element;
  790. #endif /* RTPC_REGISTER_BUG */
  791.  
  792.   CHECK_SYMBOL (sym, 0);
  793.   if (NILP (sym) || EQ (sym, Qt))
  794.     return Fsignal (Qsetting_constant, Fcons (sym, Qnil));
  795.   valcontents = XSYMBOL (sym)->value;
  796.  
  797.   if (XTYPE (valcontents) == Lisp_Buffer_Objfwd)
  798.     {
  799.       register int idx = XUINT (valcontents);
  800.       register int mask = *(int *)(idx + (char *) &buffer_local_flags);
  801.       if (mask > 0)
  802.     current_buffer->local_var_flags |= mask;
  803.     }
  804.  
  805.   else if (XTYPE (valcontents) == Lisp_Buffer_Local_Value
  806.        || XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value)
  807.     {
  808.       /* valcontents is actually a pointer to a cons heading something like:
  809.      (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE).
  810.  
  811.      BUFFER is the last buffer for which this symbol's value was
  812.      made up to date.
  813.  
  814.      CURRENT-ALIST-ELEMENT is a pointer to an element of BUFFER's
  815.      local_var_alist, that being the element whose car is this
  816.      variable.  Or it can be a pointer to the
  817.      (CURRENT-ALIST-ELEMENT . DEFAULT-VALUE), if BUFFER does not
  818.      have an element in its alist for this variable (that is, if
  819.      BUFFER sees the default value of this variable).
  820.  
  821.      If we want to examine or set the value and BUFFER is current,
  822.      we just examine or set REALVALUE. If BUFFER is not current, we
  823.      store the current REALVALUE value into CURRENT-ALIST-ELEMENT,
  824.      then find the appropriate alist element for the buffer now
  825.      current and set up CURRENT-ALIST-ELEMENT.  Then we set
  826.      REALVALUE out of that element, and store into BUFFER.
  827.  
  828.      If we are setting the variable and the current buffer does
  829.      not have an alist entry for this variable, an alist entry is
  830.      created.
  831.  
  832.      Note that REALVALUE can be a forwarding pointer.  Each time
  833.      it is examined or set, forwarding must be done.  */
  834.  
  835.       /* What value are we caching right now?  */
  836.       current_alist_element =
  837.     XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car;
  838.  
  839.       /* If the current buffer is not the buffer whose binding is
  840.      currently cached, or if it's a Lisp_Buffer_Local_Value and
  841.      we're looking at the default value, the cache is invalid; we
  842.      need to write it out, and find the new CURRENT-ALIST-ELEMENT.  */
  843.       if ((current_buffer
  844.        != XBUFFER (XCONS (XCONS (valcontents)->cdr)->car))
  845.       || (XTYPE (valcontents) == Lisp_Buffer_Local_Value
  846.           && EQ (XCONS (current_alist_element)->car,
  847.              current_alist_element)))
  848.     {
  849.       /* Write out the cached value for the old buffer; copy it
  850.          back to its alist element.  This works if the current
  851.          buffer only sees the default value, too.  */
  852.           Fsetcdr (current_alist_element,
  853.            do_symval_forwarding (XCONS (valcontents)->car));
  854.  
  855.       /* Find the new value for CURRENT-ALIST-ELEMENT.  */
  856.       tem1 = Fassq (sym, current_buffer->local_var_alist);
  857.       if (NILP (tem1))
  858.         {
  859.           /* This buffer still sees the default value.  */
  860.  
  861.           /* If the variable is a Lisp_Some_Buffer_Local_Value,
  862.          make CURRENT-ALIST-ELEMENT point to itself,
  863.          indicating that we're seeing the default value.  */
  864.           if (XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value)
  865.         tem1 = XCONS (XCONS (valcontents)->cdr)->cdr;
  866.  
  867.           /* If it's a Lisp_Buffer_Local_Value, give this buffer a
  868.          new assoc for a local value and set
  869.          CURRENT-ALIST-ELEMENT to point to that.  */
  870.           else
  871.         {
  872.           tem1 = Fcons (sym, Fcdr (current_alist_element));
  873.           current_buffer->local_var_alist =
  874.             Fcons (tem1, current_buffer->local_var_alist);
  875.         }
  876.         }
  877.       /* Cache the new buffer's assoc in CURRENT-ALIST-ELEMENT.  */
  878.       XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car = tem1;
  879.  
  880.       /* Set BUFFER, now that CURRENT-ALIST-ELEMENT is accurate.  */
  881.       XSET (XCONS (XCONS (valcontents)->cdr)->car,
  882.         Lisp_Buffer, current_buffer);
  883.     }
  884.       valcontents = XCONS (valcontents)->car;
  885.     }
  886.  
  887.   /* If storing void (making the symbol void), forward only through
  888.      buffer-local indicator, not through Lisp_Objfwd, etc.  */
  889.   if (voide)
  890.     store_symval_forwarding (sym, Qnil, newval);
  891.   else
  892.     store_symval_forwarding (sym, valcontents, newval);
  893.  
  894.   return newval;
  895. }
  896.  
  897. /* Access or set a buffer-local symbol's default value.  */
  898.  
  899. /* Return the default value of SYM, but don't check for voidness.
  900.    Return Qunbound or a Lisp_Void object if it is void.  */
  901.  
  902. Lisp_Object
  903. default_value (sym)
  904.      Lisp_Object sym;
  905. {
  906.   register Lisp_Object valcontents;
  907.  
  908.   CHECK_SYMBOL (sym, 0);
  909.   valcontents = XSYMBOL (sym)->value;
  910.  
  911.   /* For a built-in buffer-local variable, get the default value
  912.      rather than letting do_symval_forwarding get the current value.  */
  913.   if (XTYPE (valcontents) == Lisp_Buffer_Objfwd)
  914.     {
  915.       register int idx = XUINT (valcontents);
  916.  
  917.       if (*(int *) (idx + (char *) &buffer_local_flags) != 0)
  918.     return *(Lisp_Object *)(idx + (char *) &buffer_defaults);
  919.     }
  920.  
  921.   /* Handle user-created local variables.  */
  922.   if (XTYPE (valcontents) == Lisp_Buffer_Local_Value
  923.       || XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value)
  924.     {
  925.       /* If var is set up for a buffer that lacks a local value for it,
  926.      the current value is nominally the default value.
  927.      But the current value slot may be more up to date, since
  928.      ordinary setq stores just that slot.  So use that.  */
  929.       Lisp_Object current_alist_element, alist_element_car;
  930.       current_alist_element
  931.     = XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car;
  932.       alist_element_car = XCONS (current_alist_element)->car;
  933.       if (EQ (alist_element_car, current_alist_element))
  934.     return do_symval_forwarding (XCONS (valcontents)->car);
  935.       else
  936.     return XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->cdr;
  937.     }
  938.   /* For other variables, get the current value.  */
  939.   return do_symval_forwarding (valcontents);
  940. }
  941.  
  942. DEFUN ("default-boundp", Fdefault_boundp, Sdefault_boundp, 1, 1, 0,
  943.   "Return T if SYMBOL has a non-void default value.\n\
  944. This is the value that is seen in buffers that do not have their own values\n\
  945. for this variable.")
  946.   (sym)
  947.      Lisp_Object sym;
  948. {
  949.   register Lisp_Object value;
  950.  
  951.   value = default_value (sym);
  952.   return (XTYPE (value) == Lisp_Void || EQ (value, Qunbound)
  953.       ? Qnil : Qt);
  954. }
  955.  
  956. DEFUN ("default-value", Fdefault_value, Sdefault_value, 1, 1, 0,
  957.   "Return SYMBOL's default value.\n\
  958. This is the value that is seen in buffers that do not have their own values\n\
  959. for this variable.  The default value is meaningful for variables with\n\
  960. local bindings in certain buffers.")
  961.   (sym)
  962.      Lisp_Object sym;
  963. {
  964.   register Lisp_Object value;
  965.  
  966.   value = default_value (sym);
  967.   if (XTYPE (value) == Lisp_Void || EQ (value, Qunbound))
  968.     return Fsignal (Qvoid_variable, Fcons (sym, Qnil));
  969.   return value;
  970. }
  971.  
  972. DEFUN ("set-default", Fset_default, Sset_default, 2, 2, 0,
  973.   "Set SYMBOL's default value to VAL.  SYMBOL and VAL are evaluated.\n\
  974. The default value is seen in buffers that do not have their own values\n\
  975. for this variable.")
  976.   (sym, value)
  977.      Lisp_Object sym, value;
  978. {
  979.   register Lisp_Object valcontents, current_alist_element, alist_element_buffer;
  980.  
  981.   CHECK_SYMBOL (sym, 0);
  982.   valcontents = XSYMBOL (sym)->value;
  983.  
  984.   /* Handle variables like case-fold-search that have special slots
  985.      in the buffer.  Make them work apparently like Lisp_Buffer_Local_Value
  986.      variables.  */
  987.   if (XTYPE (valcontents) == Lisp_Buffer_Objfwd)
  988.     {
  989.       register int idx = XUINT (valcontents);
  990. #ifndef RTPC_REGISTER_BUG
  991.       register struct buffer *b;
  992. #else
  993.       struct buffer *b;
  994. #endif
  995.       register int mask = *(int *) (idx + (char *) &buffer_local_flags);
  996.  
  997.       if (mask > 0)
  998.     {
  999.       *(Lisp_Object *)(idx + (char *) &buffer_defaults) = value;
  1000.       for (b = all_buffers; b; b = b->next)
  1001.         if (!(b->local_var_flags & mask))
  1002.           *(Lisp_Object *)(idx + (char *) b) = value;
  1003.     }
  1004.       return value;
  1005.     }
  1006.  
  1007.   if (XTYPE (valcontents) != Lisp_Buffer_Local_Value &&
  1008.       XTYPE (valcontents) != Lisp_Some_Buffer_Local_Value)
  1009.     return Fset (sym, value);
  1010.  
  1011.   /* Store new value into the DEFAULT-VALUE slot */
  1012.   XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->cdr = value;
  1013.  
  1014.   /* If that slot is current, we must set the REALVALUE slot too */
  1015.   current_alist_element = XCONS (XCONS (XCONS (valcontents)->cdr)->cdr)->car;
  1016.   alist_element_buffer = Fcar (current_alist_element);
  1017.   if (EQ (alist_element_buffer, current_alist_element))
  1018.     store_symval_forwarding (sym, XCONS (valcontents)->car, value);
  1019.  
  1020.   return value;
  1021. }
  1022.  
  1023. DEFUN ("setq-default", Fsetq_default, Ssetq_default, 2, UNEVALLED, 0,
  1024.        "\
  1025. (setq-default SYM VAL SYM VAL ...): set each SYM's default value to its VAL.\n\
  1026. VAL is evaluated; SYM is not.  The default value is seen in buffers that do\n\
  1027. not have their own values for this variable.")
  1028.   (args)
  1029.      Lisp_Object args;
  1030. {
  1031.   register Lisp_Object args_left;
  1032.   register Lisp_Object val, sym;
  1033.   struct gcpro gcpro1;
  1034.  
  1035.   if (NILP (args))
  1036.     return Qnil;
  1037.  
  1038.   args_left = args;
  1039.   GCPRO1 (args);
  1040.  
  1041.   do
  1042.     {
  1043.       val = Feval (Fcar (Fcdr (args_left)));
  1044.       sym = Fcar (args_left);
  1045.       Fset_default (sym, val);
  1046.       args_left = Fcdr (Fcdr (args_left));
  1047.     }
  1048.   while (!NILP (args_left));
  1049.  
  1050.   UNGCPRO;
  1051.   return val;
  1052. }
  1053.  
  1054. /* Lisp functions for creating and removing buffer-local variables.  */
  1055.  
  1056. DEFUN ("make-variable-buffer-local", Fmake_variable_buffer_local, Smake_variable_buffer_local,
  1057.   1, 1, "vMake Variable Buffer Local: ",
  1058.   "Make VARIABLE have a separate value for each buffer.\n\
  1059. At any time, the value for the current buffer is in effect.\n\
  1060. There is also a default value which is seen in any buffer which has not yet\n\
  1061. set its own value.\n\
  1062. Using `set' or `setq' to set the variable causes it to have a separate value\n\
  1063. for the current buffer if it was previously using the default value.\n\
  1064. The function `default-value' gets the default value and `set-default' sets it.")
  1065.   (sym)
  1066.      register Lisp_Object sym;
  1067. {
  1068.   register Lisp_Object tem, valcontents;
  1069.  
  1070.   CHECK_SYMBOL (sym, 0);
  1071.  
  1072.   if (EQ (sym, Qnil) || EQ (sym, Qt))
  1073.     error ("Symbol %s may not be buffer-local", XSYMBOL (sym)->name->data);
  1074.  
  1075.   valcontents = XSYMBOL (sym)->value;
  1076.   if ((XTYPE (valcontents) == Lisp_Buffer_Local_Value) ||
  1077.       (XTYPE (valcontents) == Lisp_Buffer_Objfwd))
  1078.     return sym;
  1079.   if (XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value)
  1080.     {
  1081.       XSETTYPE (XSYMBOL (sym)->value, Lisp_Buffer_Local_Value);
  1082.       return sym;
  1083.     }
  1084.   if (EQ (valcontents, Qunbound))
  1085.     XSYMBOL (sym)->value = Qnil;
  1086.   tem = Fcons (Qnil, Fsymbol_value (sym));
  1087.   XCONS (tem)->car = tem;
  1088.   XSYMBOL (sym)->value = Fcons (XSYMBOL (sym)->value, Fcons (Fcurrent_buffer (), tem));
  1089.   XSETTYPE (XSYMBOL (sym)->value, Lisp_Buffer_Local_Value);
  1090.   return sym;
  1091. }
  1092.  
  1093. DEFUN ("make-local-variable", Fmake_local_variable, Smake_local_variable,
  1094.   1, 1, "vMake Local Variable: ",
  1095.   "Make VARIABLE have a separate value in the current buffer.\n\
  1096. Other buffers will continue to share a common default value.\n\
  1097. See also `make-variable-buffer-local'.\n\n\
  1098. If the variable is already arranged to become local when set,\n\
  1099. this function causes a local value to exist for this buffer,\n\
  1100. just as if the variable were set.")
  1101.   (sym)
  1102.      register Lisp_Object sym;
  1103. {
  1104.   register Lisp_Object tem, valcontents;
  1105.  
  1106.   CHECK_SYMBOL (sym, 0);
  1107.  
  1108.   if (EQ (sym, Qnil) || EQ (sym, Qt))
  1109.     error ("Symbol %s may not be buffer-local", XSYMBOL (sym)->name->data);
  1110.  
  1111.   valcontents = XSYMBOL (sym)->value;
  1112.   if (XTYPE (valcontents) == Lisp_Buffer_Local_Value
  1113.       || XTYPE (valcontents) == Lisp_Buffer_Objfwd)
  1114.     {
  1115.       tem = Fboundp (sym);
  1116.       
  1117.       /* Make sure the symbol has a local value in this particular buffer,
  1118.      by setting it to the same value it already has.  */
  1119.       Fset (sym, (EQ (tem, Qt) ? Fsymbol_value (sym) : Qunbound));
  1120.       return sym;
  1121.     }
  1122.   /* Make sure sym is set up to hold per-buffer values */
  1123.   if (XTYPE (valcontents) != Lisp_Some_Buffer_Local_Value)
  1124.     {
  1125.       if (EQ (valcontents, Qunbound))
  1126.     XSYMBOL (sym)->value = Qnil;
  1127.       tem = Fcons (Qnil, do_symval_forwarding (valcontents));
  1128.       XCONS (tem)->car = tem;
  1129.       XSYMBOL (sym)->value = Fcons (XSYMBOL (sym)->value, Fcons (Qnil, tem));
  1130.       XSETTYPE (XSYMBOL (sym)->value, Lisp_Some_Buffer_Local_Value);
  1131.     }
  1132.   /* Make sure this buffer has its own value of sym */
  1133.   tem = Fassq (sym, current_buffer->local_var_alist);
  1134.   if (NILP (tem))
  1135.     {
  1136.       current_buffer->local_var_alist
  1137.         = Fcons (Fcons (sym, XCONS (XCONS (XCONS (XSYMBOL (sym)->value)->cdr)->cdr)->cdr),
  1138.          current_buffer->local_var_alist);
  1139.  
  1140.       /* Make sure symbol does not think it is set up for this buffer;
  1141.      force it to look once again for this buffer's value */
  1142.       {
  1143.     /* This local variable avoids "expression too complex" on IBM RT.  */
  1144.     Lisp_Object xs;
  1145.     
  1146.     xs = XSYMBOL (sym)->value;
  1147.     if (current_buffer == XBUFFER (XCONS (XCONS (xs)->cdr)->car))
  1148.       XCONS (XCONS (XSYMBOL (sym)->value)->cdr)->car = Qnil; 
  1149.       }
  1150.     }
  1151.  
  1152.   /* If the symbol forwards into a C variable, then swap in the
  1153.      variable for this buffer immediately.  If C code modifies the
  1154.      variable before we swap in, then that new value will clobber the
  1155.      default value the next time we swap.  */
  1156.   valcontents = XCONS (XSYMBOL (sym)->value)->car;
  1157.   if (XTYPE (valcontents) == Lisp_Intfwd
  1158.       || XTYPE (valcontents) == Lisp_Boolfwd
  1159.       || XTYPE (valcontents) == Lisp_Objfwd)
  1160.     swap_in_symval_forwarding (sym, XSYMBOL (sym)->value);
  1161.  
  1162.   return sym;
  1163. }
  1164.  
  1165. DEFUN ("kill-local-variable", Fkill_local_variable, Skill_local_variable,
  1166.   1, 1, "vKill Local Variable: ",
  1167.   "Make VARIABLE no longer have a separate value in the current buffer.\n\
  1168. From now on the default value will apply in this buffer.")
  1169.   (sym)
  1170.      register Lisp_Object sym;
  1171. {
  1172.   register Lisp_Object tem, valcontents;
  1173.  
  1174.   CHECK_SYMBOL (sym, 0);
  1175.  
  1176.   valcontents = XSYMBOL (sym)->value;
  1177.  
  1178.   if (XTYPE (valcontents) == Lisp_Buffer_Objfwd)
  1179.     {
  1180.       register int idx = XUINT (valcontents);
  1181.       register int mask = *(int *) (idx + (char *) &buffer_local_flags);
  1182.  
  1183.       if (mask > 0)
  1184.     {
  1185.       *(Lisp_Object *)(idx + (char *) current_buffer)
  1186.         = *(Lisp_Object *)(idx + (char *) &buffer_defaults);
  1187.       current_buffer->local_var_flags &= ~mask;
  1188.     }
  1189.       return sym;
  1190.     }
  1191.  
  1192.   if (XTYPE (valcontents) != Lisp_Buffer_Local_Value &&
  1193.       XTYPE (valcontents) != Lisp_Some_Buffer_Local_Value)
  1194.     return sym;
  1195.  
  1196.   /* Get rid of this buffer's alist element, if any */
  1197.  
  1198.   tem = Fassq (sym, current_buffer->local_var_alist);
  1199.   if (!NILP (tem))
  1200.     current_buffer->local_var_alist = Fdelq (tem, current_buffer->local_var_alist);
  1201.  
  1202.   /* Make sure symbol does not think it is set up for this buffer;
  1203.      force it to look once again for this buffer's value */
  1204.   {
  1205.     Lisp_Object sv;
  1206.     sv = XSYMBOL (sym)->value;
  1207.     if (current_buffer == XBUFFER (XCONS (XCONS (sv)->cdr)->car))
  1208.       XCONS (XCONS (sv)->cdr)->car = Qnil;
  1209.   }
  1210.  
  1211.   return sym;
  1212. }
  1213.  
  1214. /* Find the function at the end of a chain of symbol function indirections.  */
  1215.  
  1216. /* If OBJECT is a symbol, find the end of its function chain and
  1217.    return the value found there.  If OBJECT is not a symbol, just
  1218.    return it.  If there is a cycle in the function chain, signal a
  1219.    cyclic-function-indirection error.
  1220.  
  1221.    This is like Findirect_function, except that it doesn't signal an
  1222.    error if the chain ends up unbound.  */
  1223. Lisp_Object
  1224. indirect_function (object)
  1225.   register Lisp_Object object;
  1226. {
  1227.   Lisp_Object tortoise, hare;
  1228.  
  1229.   hare = tortoise = object;
  1230.  
  1231.   for (;;)
  1232.     {
  1233.       if (XTYPE (hare) != Lisp_Symbol || EQ (hare, Qunbound))
  1234.     break;
  1235.       hare = XSYMBOL (hare)->function;
  1236.       if (XTYPE (hare) != Lisp_Symbol || EQ (hare, Qunbound))
  1237.     break;
  1238.       hare = XSYMBOL (hare)->function;
  1239.  
  1240.       tortoise = XSYMBOL (tortoise)->function;
  1241.  
  1242.       if (EQ (hare, tortoise))
  1243.     Fsignal (Qcyclic_function_indirection, Fcons (object, Qnil));
  1244.     }
  1245.  
  1246.   return hare;
  1247. }
  1248.  
  1249. DEFUN ("indirect-function", Findirect_function, Sindirect_function, 1, 1, 0,
  1250.   "Return the function at the end of OBJECT's function chain.\n\
  1251. If OBJECT is a symbol, follow all function indirections and return the final\n\
  1252. function binding.\n\
  1253. If OBJECT is not a symbol, just return it.\n\
  1254. Signal a void-function error if the final symbol is unbound.\n\
  1255. Signal a cyclic-function-indirection error if there is a loop in the\n\
  1256. function chain of symbols.")
  1257.   (object)
  1258.     register Lisp_Object object;
  1259. {
  1260.   Lisp_Object result;
  1261.  
  1262.   result = indirect_function (object);
  1263.  
  1264.   if (EQ (result, Qunbound))
  1265.     return Fsignal (Qvoid_function, Fcons (object, Qnil));
  1266.   return result;
  1267. }
  1268.  
  1269. /* Extract and set vector and string elements */
  1270.  
  1271. DEFUN ("aref", Faref, Saref, 2, 2, 0,
  1272.   "Return the element of ARRAY at index INDEX.\n\
  1273. ARRAY may be a vector or a string, or a byte-code object.  INDEX starts at 0.")
  1274.   (array, idx)
  1275.      register Lisp_Object array;
  1276.      Lisp_Object idx;
  1277. {
  1278.   register int idxval;
  1279.  
  1280.   CHECK_NUMBER (idx, 1);
  1281.   idxval = XINT (idx);
  1282.   if (XTYPE (array) != Lisp_Vector && XTYPE (array) != Lisp_String
  1283.       && XTYPE (array) != Lisp_Compiled)
  1284.     array = wrong_type_argument (Qarrayp, array);
  1285.   if (idxval < 0 || idxval >= XVECTOR (array)->size)
  1286.     args_out_of_range (array, idx);
  1287.   if (XTYPE (array) == Lisp_String)
  1288.     {
  1289.       Lisp_Object val;
  1290.       XFASTINT (val) = (unsigned char) XSTRING (array)->data[idxval];
  1291.       return val;
  1292.     }
  1293.   else
  1294.     return XVECTOR (array)->contents[idxval];
  1295. }
  1296.  
  1297. DEFUN ("aset", Faset, Saset, 3, 3, 0,
  1298.   "Store into the element of ARRAY at index INDEX the value NEWVAL.\n\
  1299. ARRAY may be a vector or a string.  INDEX starts at 0.")
  1300.   (array, idx, newelt)
  1301.      register Lisp_Object array;
  1302.      Lisp_Object idx, newelt;
  1303. {
  1304.   register int idxval;
  1305.  
  1306.   CHECK_NUMBER (idx, 1);
  1307.   idxval = XINT (idx);
  1308.   if (XTYPE (array) != Lisp_Vector && XTYPE (array) != Lisp_String)
  1309.     array = wrong_type_argument (Qarrayp, array);
  1310.   if (idxval < 0 || idxval >= XVECTOR (array)->size)
  1311.     args_out_of_range (array, idx);
  1312.   CHECK_IMPURE (array);
  1313.  
  1314.   if (XTYPE (array) == Lisp_Vector)
  1315.     XVECTOR (array)->contents[idxval] = newelt;
  1316.   else
  1317.     {
  1318.       CHECK_NUMBER (newelt, 2);
  1319.       XSTRING (array)->data[idxval] = XINT (newelt);
  1320.     }
  1321.  
  1322.   return newelt;
  1323. }
  1324.  
  1325. Lisp_Object
  1326. Farray_length (array)
  1327.      register Lisp_Object array;
  1328. {
  1329.   register Lisp_Object size;
  1330.   if (XTYPE (array) != Lisp_Vector && XTYPE (array) != Lisp_String
  1331.       && XTYPE (array) != Lisp_Compiled)
  1332.     array = wrong_type_argument (Qarrayp, array);
  1333.   XFASTINT (size) = XVECTOR (array)->size;
  1334.   return size;
  1335. }
  1336.  
  1337. /* Arithmetic functions */
  1338.  
  1339. enum comparison { equal, notequal, less, grtr, less_or_equal, grtr_or_equal };
  1340.  
  1341. static Lisp_Object arithcompare _P_((Lisp_Object num1, Lisp_Object num2,
  1342.                                      enum comparison comparison));
  1343.  
  1344. static Lisp_Object
  1345. arithcompare (num1, num2, comparison)
  1346.      Lisp_Object num1, num2;
  1347.      enum comparison comparison;
  1348. {
  1349.   double f1, f2;
  1350.   int floatp = 0;
  1351.  
  1352. #ifdef LISP_FLOAT_TYPE
  1353.   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  1354.   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
  1355.  
  1356.   if (XTYPE (num1) == Lisp_Float || XTYPE (num2) == Lisp_Float)
  1357.     {
  1358.       floatp = 1;
  1359.       f1 = (XTYPE (num1) == Lisp_Float) ? XFLOAT (num1)->data : XINT (num1);
  1360.       f2 = (XTYPE (num2) == Lisp_Float) ? XFLOAT (num2)->data : XINT (num2);
  1361.     }
  1362. #else
  1363.   CHECK_NUMBER_COERCE_MARKER (num1, 0);
  1364.   CHECK_NUMBER_COERCE_MARKER (num2, 0);
  1365. #endif /* LISP_FLOAT_TYPE */
  1366.  
  1367.   switch (comparison)
  1368.     {
  1369.     case equal:
  1370.       if (floatp ? f1 == f2 : XINT (num1) == XINT (num2))
  1371.     return Qt;
  1372.       return Qnil;
  1373.  
  1374.     case notequal:
  1375.       if (floatp ? f1 != f2 : XINT (num1) != XINT (num2))
  1376.     return Qt;
  1377.       return Qnil;
  1378.  
  1379.     case less:
  1380.       if (floatp ? f1 < f2 : XINT (num1) < XINT (num2))
  1381.     return Qt;
  1382.       return Qnil;
  1383.  
  1384.     case less_or_equal:
  1385.       if (floatp ? f1 <= f2 : XINT (num1) <= XINT (num2))
  1386.     return Qt;
  1387.       return Qnil;
  1388.  
  1389.     case grtr:
  1390.       if (floatp ? f1 > f2 : XINT (num1) > XINT (num2))
  1391.     return Qt;
  1392.       return Qnil;
  1393.  
  1394.     case grtr_or_equal:
  1395.       if (floatp ? f1 >= f2 : XINT (num1) >= XINT (num2))
  1396.     return Qt;
  1397.       return Qnil;
  1398.  
  1399.     default:
  1400.       abort ();
  1401.     }
  1402. }
  1403.  
  1404. DEFUN ("=", Feqlsign, Seqlsign, 2, 2, 0,
  1405.   "T if two args, both numbers or markers, are equal.")
  1406.   (num1, num2)
  1407.      register Lisp_Object num1, num2;
  1408. {
  1409.   return arithcompare (num1, num2, equal);
  1410. }
  1411.  
  1412. DEFUN ("<", Flss, Slss, 2, 2, 0,
  1413.   "T if first arg is less than second arg.  Both must be numbers or markers.")
  1414.   (num1, num2)
  1415.      register Lisp_Object num1, num2;
  1416. {
  1417.   return arithcompare (num1, num2, less);
  1418. }
  1419.  
  1420. DEFUN (">", Fgtr, Sgtr, 2, 2, 0,
  1421.   "T if first arg is greater than second arg.  Both must be numbers or markers.")
  1422.   (num1, num2)
  1423.      register Lisp_Object num1, num2;
  1424. {
  1425.   return arithcompare (num1, num2, grtr);
  1426. }
  1427.  
  1428. DEFUN ("<=", Fleq, Sleq, 2, 2, 0,
  1429.   "T if first arg is less than or equal to second arg.\n\
  1430. Both must be numbers or markers.")
  1431.   (num1, num2)
  1432.      register Lisp_Object num1, num2;
  1433. {
  1434.   return arithcompare (num1, num2, less_or_equal);
  1435. }
  1436.  
  1437. DEFUN (">=", Fgeq, Sgeq, 2, 2, 0,
  1438.   "T if first arg is greater than or equal to second arg.\n\
  1439. Both must be numbers or markers.")
  1440.   (num1, num2)
  1441.      register Lisp_Object num1, num2;
  1442. {
  1443.   return arithcompare (num1, num2, grtr_or_equal);
  1444. }
  1445.  
  1446. DEFUN ("/=", Fneq, Sneq, 2, 2, 0,
  1447.   "T if first arg is not equal to second arg.  Both must be numbers or markers.")
  1448.   (num1, num2)
  1449.      register Lisp_Object num1, num2;
  1450. {
  1451.   return arithcompare (num1, num2, notequal);
  1452. }
  1453.  
  1454. DEFUN ("zerop", Fzerop, Szerop, 1, 1, 0, "T if NUMBER is zero.")
  1455.   (num)
  1456.      register Lisp_Object num;
  1457. {
  1458. #ifdef LISP_FLOAT_TYPE
  1459.   CHECK_NUMBER_OR_FLOAT (num, 0);
  1460.  
  1461.   if (XTYPE(num) == Lisp_Float)
  1462.     {
  1463.       if (XFLOAT(num)->data == 0.0)
  1464.     return Qt;
  1465.       return Qnil;
  1466.     }
  1467. #else
  1468.   CHECK_NUMBER (num, 0);
  1469. #endif /* LISP_FLOAT_TYPE */
  1470.  
  1471.   if (!XINT (num))
  1472.     return Qt;
  1473.   return Qnil;
  1474. }
  1475.  
  1476. /* Convert between 32-bit values and pairs of lispy 24-bit values.  */
  1477.  
  1478. Lisp_Object
  1479. long_to_cons (i)
  1480.      unsigned long i;
  1481. {
  1482.   unsigned int top = i >> 16;
  1483.   unsigned int bot = i & 0xFFFF;
  1484.   if (top == 0)
  1485.     return make_number (bot);
  1486.   if (top == 0xFFFF)
  1487.     return Fcons (make_number (-1), make_number (bot));
  1488.   return Fcons (make_number (top), make_number (bot));
  1489. }
  1490.  
  1491. unsigned long
  1492. cons_to_long (c)
  1493.      Lisp_Object c;
  1494. {
  1495.   Lisp_Object top, bot;
  1496.   if (INTEGERP (c))
  1497.     return XINT (c);
  1498.   top = XCONS (c)->car;
  1499.   bot = XCONS (c)->cdr;
  1500.   if (CONSP (bot))
  1501.     bot = XCONS (bot)->car;
  1502.   return ((XINT (top) << 16) | XINT (bot));
  1503. }
  1504.  
  1505. DEFUN ("number-to-string", Fnumber_to_string, Snumber_to_string, 1, 1, 0,
  1506.   "Convert NUM to a string by printing it in decimal.\n\
  1507. Uses a minus sign if negative.\n\
  1508. NUM may be an integer or a floating point number.")
  1509.   (num)
  1510.      Lisp_Object num;
  1511. {
  1512.   char buffer[20];
  1513.  
  1514. #ifndef LISP_FLOAT_TYPE
  1515.   CHECK_NUMBER (num, 0);
  1516. #else
  1517.   CHECK_NUMBER_OR_FLOAT (num, 0);
  1518.  
  1519.   if (XTYPE(num) == Lisp_Float)
  1520.     {
  1521.       char pigbuf[350];    /* see comments in float_to_string */
  1522.  
  1523.       float_to_string (pigbuf, XFLOAT(num)->data);
  1524.       return build_string (pigbuf);      
  1525.     }
  1526. #endif /* LISP_FLOAT_TYPE */
  1527.  
  1528.   sprintf (buffer, "%d", XINT (num));
  1529.   return build_string (buffer);
  1530. }
  1531.  
  1532. DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 1, 0,
  1533.   "Convert STRING to a number by parsing it as a decimal number.\n\
  1534. This parses both integers and floating point numbers.")
  1535.   (str)
  1536.      register Lisp_Object str;
  1537. {
  1538.   unsigned char *p;
  1539.  
  1540.   CHECK_STRING (str, 0);
  1541.  
  1542.   p = XSTRING (str)->data;
  1543.  
  1544.   /* Skip any whitespace at the front of the number.  Some versions of
  1545.      atoi do this anyway, so we might as well make Emacs lisp consistent.  */
  1546.   while (*p == ' ' || *p == '\t')
  1547.     p++;
  1548.  
  1549. #ifdef LISP_FLOAT_TYPE
  1550.   if (isfloat_string (p))
  1551.     return make_float (atof (p));
  1552. #endif /* LISP_FLOAT_TYPE */
  1553.  
  1554.   return make_number (atoi (p));
  1555. }
  1556.   
  1557. enum arithop
  1558.   { Aadd, Asub, Amult, Adiv, Alogand, Alogior, Alogxor, Amax, Amin };
  1559.  
  1560. static Lisp_Object arith_driver _P_((enum arithop code, int nargs,
  1561.                                      register Lisp_Object *args));
  1562. static Lisp_Object float_arith_driver _P_((double accum, register int argnum,
  1563.                                            enum arithop code, int nargs,
  1564.                                            register Lisp_Object *args));
  1565.  
  1566. static Lisp_Object
  1567. arith_driver (code, nargs, args)
  1568.      enum arithop code;
  1569.      int nargs;
  1570.      register Lisp_Object *args;
  1571. {
  1572.   register Lisp_Object val;
  1573.   register int argnum;
  1574.   register int accum;
  1575.   register int next;
  1576.  
  1577. #ifdef SWITCH_ENUM_BUG
  1578.   switch ((int) code)
  1579. #else
  1580.   switch (code)
  1581. #endif
  1582.     {
  1583.     case Alogior:
  1584.     case Alogxor:
  1585.     case Aadd:
  1586.     case Asub:
  1587.       accum = 0; break;
  1588.     case Amult:
  1589.       accum = 1; break;
  1590.     case Alogand:
  1591.       accum = -1; break;
  1592.     }
  1593.  
  1594.   for (argnum = 0; argnum < nargs; argnum++)
  1595.     {
  1596.       val = args[argnum];    /* using args[argnum] as argument to CHECK_NUMBER_... */
  1597. #ifdef LISP_FLOAT_TYPE
  1598.       CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val, argnum);
  1599.  
  1600.       if (XTYPE (val) == Lisp_Float) /* time to do serious math */
  1601.     return (float_arith_driver ((double) accum, argnum, code,
  1602.                     nargs, args));
  1603. #else
  1604.       CHECK_NUMBER_COERCE_MARKER (val, argnum);
  1605. #endif /* LISP_FLOAT_TYPE */
  1606.       args[argnum] = val;    /* runs into a compiler bug. */
  1607.       next = XINT (args[argnum]);
  1608. #ifdef SWITCH_ENUM_BUG
  1609.       switch ((int) code)
  1610. #else
  1611.       switch (code)
  1612. #endif
  1613.     {
  1614.     case Aadd: accum += next; break;
  1615.     case Asub:
  1616.       if (!argnum && nargs != 1)
  1617.         next = - next;
  1618.       accum -= next;
  1619.       break;
  1620.     case Amult: accum *= next; break;
  1621.     case Adiv:
  1622.       if (!argnum) accum = next;
  1623.       else
  1624.         {
  1625.           if (next == 0)
  1626.         Fsignal (Qarith_error, Qnil);
  1627.           accum /= next;
  1628.         }
  1629.       break;
  1630.     case Alogand: accum &= next; break;
  1631.     case Alogior: accum |= next; break;
  1632.     case Alogxor: accum ^= next; break;
  1633.     case Amax: if (!argnum || next > accum) accum = next; break;
  1634.     case Amin: if (!argnum || next < accum) accum = next; break;
  1635.     }
  1636.     }
  1637.  
  1638.   XSET (val, Lisp_Int, accum);
  1639.   return val;
  1640. }
  1641.  
  1642. #ifdef LISP_FLOAT_TYPE
  1643. static Lisp_Object
  1644. float_arith_driver (accum, argnum, code, nargs, args)
  1645.      double accum;
  1646.      register int argnum;
  1647.      enum arithop code;
  1648.      int nargs;
  1649.      register Lisp_Object *args;
  1650. {
  1651.   register Lisp_Object val;
  1652.   double next;
  1653.   
  1654.   for (; argnum < nargs; argnum++)
  1655.     {
  1656.       val = args[argnum];    /* using args[argnum] as argument to CHECK_NUMBER_... */
  1657.       CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val, argnum);
  1658.  
  1659.       if (XTYPE (val) == Lisp_Float)
  1660.     {
  1661.       next = XFLOAT (val)->data;
  1662.     }
  1663.       else
  1664.     {
  1665.       args[argnum] = val;    /* runs into a compiler bug. */
  1666.       next = XINT (args[argnum]);
  1667.     }
  1668. #ifdef SWITCH_ENUM_BUG
  1669.       switch ((int) code)
  1670. #else
  1671.       switch (code)
  1672. #endif
  1673.     {
  1674.     case Aadd:
  1675.       accum += next;
  1676.       break;
  1677.     case Asub:
  1678.       if (!argnum && nargs != 1)
  1679.         next = - next;
  1680.       accum -= next;
  1681.       break;
  1682.     case Amult:
  1683.       accum *= next;
  1684.       break;
  1685.     case Adiv:
  1686.       if (!argnum)
  1687.         accum = next;
  1688.       else
  1689.         {
  1690.           if (next == 0)
  1691.         Fsignal (Qarith_error, Qnil);
  1692.           accum /= next;
  1693.         }
  1694.       break;
  1695.     case Alogand:
  1696.     case Alogior:
  1697.     case Alogxor:
  1698.       return wrong_type_argument (Qinteger_or_marker_p, val);
  1699.     case Amax:
  1700.       if (!argnum || next > accum)
  1701.         accum = next;
  1702.       break;
  1703.     case Amin:
  1704.       if (!argnum || next < accum)
  1705.         accum = next;
  1706.       break;
  1707.     }
  1708.     }
  1709.  
  1710.   return make_float (accum);
  1711. }
  1712. #endif /* LISP_FLOAT_TYPE */
  1713.  
  1714. DEFUN ("+", Fplus, Splus, 0, MANY, 0,
  1715.   "Return sum of any number of arguments, which are numbers or markers.")
  1716.   (nargs, args)
  1717.      int nargs;
  1718.      Lisp_Object *args;
  1719. {
  1720.   return arith_driver (Aadd, nargs, args);
  1721. }
  1722.  
  1723. DEFUN ("-", Fminus, Sminus, 0, MANY, 0,
  1724.   "Negate number or subtract numbers or markers.\n\
  1725. With one arg, negates it.  With more than one arg,\n\
  1726. subtracts all but the first from the first.")
  1727.   (nargs, args)
  1728.      int nargs;
  1729.      Lisp_Object *args;
  1730. {
  1731.   return arith_driver (Asub, nargs, args);
  1732. }
  1733.  
  1734. DEFUN ("*", Ftimes, Stimes, 0, MANY, 0,
  1735.   "Returns product of any number of arguments, which are numbers or markers.")
  1736.   (nargs, args)
  1737.      int nargs;
  1738.      Lisp_Object *args;
  1739. {
  1740.   return arith_driver (Amult, nargs, args);
  1741. }
  1742.  
  1743. DEFUN ("/", Fquo, Squo, 2, MANY, 0,
  1744.   "Returns first argument divided by all the remaining arguments.\n\
  1745. The arguments must be numbers or markers.")
  1746.   (nargs, args)
  1747.      int nargs;
  1748.      Lisp_Object *args;
  1749. {
  1750.   return arith_driver (Adiv, nargs, args);
  1751. }
  1752.  
  1753. DEFUN ("%", Frem, Srem, 2, 2, 0,
  1754.   "Returns remainder of first arg divided by second.\n\
  1755. Both must be numbers or markers.")
  1756.   (num1, num2)
  1757.      register Lisp_Object num1, num2;
  1758. {
  1759.   Lisp_Object val;
  1760.  
  1761. #ifdef LISP_FLOAT_TYPE
  1762.   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  1763.   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
  1764.  
  1765.   if (XTYPE (num1) == Lisp_Float || XTYPE (num2) == Lisp_Float)
  1766.     {
  1767.       double f1, f2;
  1768.  
  1769.       f1 = XTYPE (num1) == Lisp_Float ? XFLOAT (num1)->data : XINT (num1);
  1770.       f2 = XTYPE (num2) == Lisp_Float ? XFLOAT (num2)->data : XINT (num2);
  1771.       if (f2 == 0)
  1772.     Fsignal (Qarith_error, Qnil);
  1773.  
  1774. #if defined (USG) || defined (sun) || defined (ultrix) || defined (hpux) || \
  1775.     defined (WINDOWSNT)
  1776.       f1 = fmod (f1, f2);
  1777. #else
  1778.       f1 = drem (f1, f2);
  1779. #endif
  1780.       /* If the "remainder" comes out with the wrong sign, fix it.  */
  1781.       if ((f1 < 0) != (f2 < 0))
  1782.     f1 += f2;
  1783.       return (make_float (f1));
  1784.     }
  1785. #else /* not LISP_FLOAT_TYPE */
  1786.   CHECK_NUMBER_COERCE_MARKER (num1, 0);
  1787.   CHECK_NUMBER_COERCE_MARKER (num2, 1);
  1788. #endif /* not LISP_FLOAT_TYPE */
  1789.  
  1790.   if (XFASTINT (num2) == 0)
  1791.     Fsignal (Qarith_error, Qnil);
  1792.  
  1793.   XSET (val, Lisp_Int, XINT (num1) % XINT (num2));
  1794.   return val;
  1795. }
  1796.  
  1797. DEFUN ("max", Fmax, Smax, 1, MANY, 0,
  1798.   "Return largest of all the arguments (which must be numbers or markers).\n\
  1799. The value is always a number; markers are converted to numbers.")
  1800.   (nargs, args)
  1801.      int nargs;
  1802.      Lisp_Object *args;
  1803. {
  1804.   return arith_driver (Amax, nargs, args);
  1805. }
  1806.  
  1807. DEFUN ("min", Fmin, Smin, 1, MANY, 0,
  1808.   "Return smallest of all the arguments (which must be numbers or markers).\n\
  1809. The value is always a number; markers are converted to numbers.")
  1810.   (nargs, args)
  1811.      int nargs;
  1812.      Lisp_Object *args;
  1813. {
  1814.   return arith_driver (Amin, nargs, args);
  1815. }
  1816.  
  1817. DEFUN ("logand", Flogand, Slogand, 0, MANY, 0,
  1818.   "Return bitwise-and of all the arguments.\n\
  1819. Arguments may be integers, or markers converted to integers.")
  1820.   (nargs, args)
  1821.      int nargs;
  1822.      Lisp_Object *args;
  1823. {
  1824.   return arith_driver (Alogand, nargs, args);
  1825. }
  1826.  
  1827. DEFUN ("logior", Flogior, Slogior, 0, MANY, 0,
  1828.   "Return bitwise-or of all the arguments.\n\
  1829. Arguments may be integers, or markers converted to integers.")
  1830.   (nargs, args)
  1831.      int nargs;
  1832.      Lisp_Object *args;
  1833. {
  1834.   return arith_driver (Alogior, nargs, args);
  1835. }
  1836.  
  1837. DEFUN ("logxor", Flogxor, Slogxor, 0, MANY, 0,
  1838.   "Return bitwise-exclusive-or of all the arguments.\n\
  1839. Arguments may be integers, or markers converted to integers.")
  1840.   (nargs, args)
  1841.      int nargs;
  1842.      Lisp_Object *args;
  1843. {
  1844.   return arith_driver (Alogxor, nargs, args);
  1845. }
  1846.  
  1847. DEFUN ("ash", Fash, Sash, 2, 2, 0,
  1848.   "Return VALUE with its bits shifted left by COUNT.\n\
  1849. If COUNT is negative, shifting is actually to the right.\n\
  1850. In this case, the sign bit is duplicated.")
  1851.   (num1, num2)
  1852.      register Lisp_Object num1, num2;
  1853. {
  1854.   register Lisp_Object val;
  1855.  
  1856.   CHECK_NUMBER (num1, 0);
  1857.   CHECK_NUMBER (num2, 1);
  1858.  
  1859.   if (XINT (num2) > 0)
  1860.     XSET (val, Lisp_Int, XINT (num1) << XFASTINT (num2));
  1861.   else
  1862.     XSET (val, Lisp_Int, XINT (num1) >> -XINT (num2));
  1863.   return val;
  1864. }
  1865.  
  1866. DEFUN ("lsh", Flsh, Slsh, 2, 2, 0,
  1867.   "Return VALUE with its bits shifted left by COUNT.\n\
  1868. If COUNT is negative, shifting is actually to the right.\n\
  1869. In this case,  zeros are shifted in on the left.")
  1870.   (num1, num2)
  1871.      register Lisp_Object num1, num2;
  1872. {
  1873.   register Lisp_Object val;
  1874.  
  1875.   CHECK_NUMBER (num1, 0);
  1876.   CHECK_NUMBER (num2, 1);
  1877.  
  1878.   if (XINT (num2) > 0)
  1879.     XSET (val, Lisp_Int, (unsigned) XFASTINT (num1) << XFASTINT (num2));
  1880.   else
  1881.     XSET (val, Lisp_Int, (unsigned) XFASTINT (num1) >> -XINT (num2));
  1882.   return val;
  1883. }
  1884.  
  1885. DEFUN ("1+", Fadd1, Sadd1, 1, 1, 0,
  1886.   "Return NUMBER plus one.  NUMBER may be a number or a marker.\n\
  1887. Markers are converted to integers.")
  1888.   (num)
  1889.      register Lisp_Object num;
  1890. {
  1891. #ifdef LISP_FLOAT_TYPE
  1892.   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num, 0);
  1893.  
  1894.   if (XTYPE (num) == Lisp_Float)
  1895.     return (make_float (1.0 + XFLOAT (num)->data));
  1896. #else
  1897.   CHECK_NUMBER_COERCE_MARKER (num, 0);
  1898. #endif /* LISP_FLOAT_TYPE */
  1899.  
  1900.   XSETINT (num, XFASTINT (num) + 1);
  1901.   return num;
  1902. }
  1903.  
  1904. DEFUN ("1-", Fsub1, Ssub1, 1, 1, 0,
  1905.   "Return NUMBER minus one.  NUMBER may be a number or a marker.\n\
  1906. Markers are converted to integers.")
  1907.   (num)
  1908.      register Lisp_Object num;
  1909. {
  1910. #ifdef LISP_FLOAT_TYPE
  1911.   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num, 0);
  1912.  
  1913.   if (XTYPE (num) == Lisp_Float)
  1914.     return (make_float (-1.0 + XFLOAT (num)->data));
  1915. #else
  1916.   CHECK_NUMBER_COERCE_MARKER (num, 0);
  1917. #endif /* LISP_FLOAT_TYPE */
  1918.  
  1919.   XSETINT (num, XFASTINT (num) - 1);
  1920.   return num;
  1921. }
  1922.  
  1923. DEFUN ("lognot", Flognot, Slognot, 1, 1, 0,
  1924.   "Return the bitwise complement of ARG.  ARG must be an integer.")
  1925.   (num)
  1926.      register Lisp_Object num;
  1927. {
  1928.   CHECK_NUMBER (num, 0);
  1929.   XSETINT (num, ~XFASTINT (num));
  1930.   return num;
  1931. }
  1932.  
  1933. void
  1934. syms_of_data ()
  1935. {
  1936.   Lisp_Object error_tail, arith_tail;
  1937.  
  1938.   Qquote = intern ("quote");
  1939.   Qlambda = intern ("lambda");
  1940.   Qsubr = intern ("subr");
  1941.   Qerror_conditions = intern ("error-conditions");
  1942.   Qerror_message = intern ("error-message");
  1943.   Qtop_level = intern ("top-level");
  1944.  
  1945.   Qerror = intern ("error");
  1946.   Qquit = intern ("quit");
  1947.   Qwrong_type_argument = intern ("wrong-type-argument");
  1948.   Qargs_out_of_range = intern ("args-out-of-range");
  1949.   Qvoid_function = intern ("void-function");
  1950.   Qcyclic_function_indirection = intern ("cyclic-function-indirection");
  1951.   Qvoid_variable = intern ("void-variable");
  1952.   Qsetting_constant = intern ("setting-constant");
  1953.   Qinvalid_read_syntax = intern ("invalid-read-syntax");
  1954.  
  1955.   Qinvalid_function = intern ("invalid-function");
  1956.   Qwrong_number_of_arguments = intern ("wrong-number-of-arguments");
  1957.   Qno_catch = intern ("no-catch");
  1958.   Qend_of_file = intern ("end-of-file");
  1959.   Qarith_error = intern ("arith-error");
  1960.   Qbeginning_of_buffer = intern ("beginning-of-buffer");
  1961.   Qend_of_buffer = intern ("end-of-buffer");
  1962.   Qbuffer_read_only = intern ("buffer-read-only");
  1963.   Qmark_inactive = intern ("mark-inactive");
  1964.  
  1965.   Qlistp = intern ("listp");
  1966.   Qconsp = intern ("consp");
  1967.   Qsymbolp = intern ("symbolp");
  1968.   Qintegerp = intern ("integerp");
  1969.   Qnatnump = intern ("natnump");
  1970.   Qstringp = intern ("stringp");
  1971.   Qarrayp = intern ("arrayp");
  1972.   Qsequencep = intern ("sequencep");
  1973.   Qbufferp = intern ("bufferp");
  1974.   Qvectorp = intern ("vectorp");
  1975.   Qchar_or_string_p = intern ("char-or-string-p");
  1976.   Qmarkerp = intern ("markerp");
  1977.   Qbuffer_or_string_p = intern ("buffer-or-string-p");
  1978.   Qinteger_or_marker_p = intern ("integer-or-marker-p");
  1979.   Qboundp = intern ("boundp");
  1980.   Qfboundp = intern ("fboundp");
  1981.  
  1982. #ifdef LISP_FLOAT_TYPE
  1983.   Qfloatp = intern ("floatp");
  1984.   Qnumberp = intern ("numberp");
  1985.   Qnumber_or_marker_p = intern ("number-or-marker-p");
  1986. #endif /* LISP_FLOAT_TYPE */
  1987.  
  1988.   Qcdr = intern ("cdr");
  1989.  
  1990.   error_tail = Fcons (Qerror, Qnil);
  1991.  
  1992.   /* ERROR is used as a signaler for random errors for which nothing else is right */
  1993.  
  1994.   Fput (Qerror, Qerror_conditions,
  1995.     error_tail);
  1996.   Fput (Qerror, Qerror_message,
  1997.     build_string ("error"));
  1998.  
  1999.   Fput (Qquit, Qerror_conditions,
  2000.     Fcons (Qquit, Qnil));
  2001.   Fput (Qquit, Qerror_message,
  2002.     build_string ("Quit"));
  2003.  
  2004.   Fput (Qwrong_type_argument, Qerror_conditions,
  2005.     Fcons (Qwrong_type_argument, error_tail));
  2006.   Fput (Qwrong_type_argument, Qerror_message,
  2007.     build_string ("Wrong type argument"));
  2008.  
  2009.   Fput (Qargs_out_of_range, Qerror_conditions,
  2010.     Fcons (Qargs_out_of_range, error_tail));
  2011.   Fput (Qargs_out_of_range, Qerror_message,
  2012.     build_string ("Args out of range"));
  2013.  
  2014.   Fput (Qvoid_function, Qerror_conditions,
  2015.     Fcons (Qvoid_function, error_tail));
  2016.   Fput (Qvoid_function, Qerror_message,
  2017.     build_string ("Symbol's function definition is void"));
  2018.  
  2019.   Fput (Qcyclic_function_indirection, Qerror_conditions,
  2020.     Fcons (Qcyclic_function_indirection, error_tail));
  2021.   Fput (Qcyclic_function_indirection, Qerror_message,
  2022.     build_string ("Symbol's chain of function indirections contains a loop"));
  2023.  
  2024.   Fput (Qvoid_variable, Qerror_conditions,
  2025.     Fcons (Qvoid_variable, error_tail));
  2026.   Fput (Qvoid_variable, Qerror_message,
  2027.     build_string ("Symbol's value as variable is void"));
  2028.  
  2029.   Fput (Qsetting_constant, Qerror_conditions,
  2030.     Fcons (Qsetting_constant, error_tail));
  2031.   Fput (Qsetting_constant, Qerror_message,
  2032.     build_string ("Attempt to set a constant symbol"));
  2033.  
  2034.   Fput (Qinvalid_read_syntax, Qerror_conditions,
  2035.     Fcons (Qinvalid_read_syntax, error_tail));
  2036.   Fput (Qinvalid_read_syntax, Qerror_message,
  2037.     build_string ("Invalid read syntax"));
  2038.  
  2039.   Fput (Qinvalid_function, Qerror_conditions,
  2040.     Fcons (Qinvalid_function, error_tail));
  2041.   Fput (Qinvalid_function, Qerror_message,
  2042.     build_string ("Invalid function"));
  2043.  
  2044.   Fput (Qwrong_number_of_arguments, Qerror_conditions,
  2045.     Fcons (Qwrong_number_of_arguments, error_tail));
  2046.   Fput (Qwrong_number_of_arguments, Qerror_message,
  2047.     build_string ("Wrong number of arguments"));
  2048.  
  2049.   Fput (Qno_catch, Qerror_conditions,
  2050.     Fcons (Qno_catch, error_tail));
  2051.   Fput (Qno_catch, Qerror_message,
  2052.     build_string ("No catch for tag"));
  2053.  
  2054.   Fput (Qend_of_file, Qerror_conditions,
  2055.     Fcons (Qend_of_file, error_tail));
  2056.   Fput (Qend_of_file, Qerror_message,
  2057.     build_string ("End of file during parsing"));
  2058.  
  2059.   arith_tail = Fcons (Qarith_error, error_tail);
  2060.   Fput (Qarith_error, Qerror_conditions,
  2061.     arith_tail);
  2062.   Fput (Qarith_error, Qerror_message,
  2063.     build_string ("Arithmetic error"));
  2064.  
  2065.   Fput (Qbeginning_of_buffer, Qerror_conditions,
  2066.     Fcons (Qbeginning_of_buffer, error_tail));
  2067.   Fput (Qbeginning_of_buffer, Qerror_message,
  2068.     build_string ("Beginning of buffer"));
  2069.  
  2070.   Fput (Qend_of_buffer, Qerror_conditions,
  2071.     Fcons (Qend_of_buffer, error_tail));
  2072.   Fput (Qend_of_buffer, Qerror_message,
  2073.     build_string ("End of buffer"));
  2074.  
  2075.   Fput (Qbuffer_read_only, Qerror_conditions,
  2076.     Fcons (Qbuffer_read_only, error_tail));
  2077.   Fput (Qbuffer_read_only, Qerror_message,
  2078.     build_string ("Buffer is read-only"));
  2079.  
  2080. #ifdef LISP_FLOAT_TYPE
  2081.   Qrange_error = intern ("range-error");
  2082.   Qdomain_error = intern ("domain-error");
  2083.   Qsingularity_error = intern ("singularity-error");
  2084.   Qoverflow_error = intern ("overflow-error");
  2085.   Qunderflow_error = intern ("underflow-error");
  2086.  
  2087.   Fput (Qdomain_error, Qerror_conditions,
  2088.     Fcons (Qdomain_error, arith_tail));
  2089.   Fput (Qdomain_error, Qerror_message,
  2090.     build_string ("Arithmetic domain error"));
  2091.  
  2092.   Fput (Qrange_error, Qerror_conditions,
  2093.     Fcons (Qrange_error, arith_tail));
  2094.   Fput (Qrange_error, Qerror_message,
  2095.     build_string ("Arithmetic range error"));
  2096.  
  2097.   Fput (Qsingularity_error, Qerror_conditions,
  2098.     Fcons (Qsingularity_error, Fcons (Qdomain_error, arith_tail)));
  2099.   Fput (Qsingularity_error, Qerror_message,
  2100.     build_string ("Arithmetic singularity error"));
  2101.  
  2102.   Fput (Qoverflow_error, Qerror_conditions,
  2103.     Fcons (Qoverflow_error, Fcons (Qdomain_error, arith_tail)));
  2104.   Fput (Qoverflow_error, Qerror_message,
  2105.     build_string ("Arithmetic overflow error"));
  2106.  
  2107.   Fput (Qunderflow_error, Qerror_conditions,
  2108.     Fcons (Qunderflow_error, Fcons (Qdomain_error, arith_tail)));
  2109.   Fput (Qunderflow_error, Qerror_message,
  2110.     build_string ("Arithmetic underflow error"));
  2111.  
  2112.   staticpro (&Qrange_error);
  2113.   staticpro (&Qdomain_error);
  2114.   staticpro (&Qsingularity_error);
  2115.   staticpro (&Qoverflow_error);
  2116.   staticpro (&Qunderflow_error);
  2117. #endif /* LISP_FLOAT_TYPE */
  2118.  
  2119.   staticpro (&Qnil);
  2120.   staticpro (&Qt);
  2121.   staticpro (&Qquote);
  2122.   staticpro (&Qlambda);
  2123.   staticpro (&Qsubr);
  2124.   staticpro (&Qunbound);
  2125.   staticpro (&Qerror_conditions);
  2126.   staticpro (&Qerror_message);
  2127.   staticpro (&Qtop_level);
  2128.  
  2129.   staticpro (&Qerror);
  2130.   staticpro (&Qquit);
  2131.   staticpro (&Qwrong_type_argument);
  2132.   staticpro (&Qargs_out_of_range);
  2133.   staticpro (&Qvoid_function);
  2134.   staticpro (&Qcyclic_function_indirection);
  2135.   staticpro (&Qvoid_variable);
  2136.   staticpro (&Qsetting_constant);
  2137.   staticpro (&Qinvalid_read_syntax);
  2138.   staticpro (&Qwrong_number_of_arguments);
  2139.   staticpro (&Qinvalid_function);
  2140.   staticpro (&Qno_catch);
  2141.   staticpro (&Qend_of_file);
  2142.   staticpro (&Qarith_error);
  2143.   staticpro (&Qbeginning_of_buffer);
  2144.   staticpro (&Qend_of_buffer);
  2145.   staticpro (&Qbuffer_read_only);
  2146.   staticpro (&Qmark_inactive);
  2147.  
  2148.   staticpro (&Qlistp);
  2149.   staticpro (&Qconsp);
  2150.   staticpro (&Qsymbolp);
  2151.   staticpro (&Qintegerp);
  2152.   staticpro (&Qnatnump);
  2153.   staticpro (&Qstringp);
  2154.   staticpro (&Qarrayp);
  2155.   staticpro (&Qsequencep);
  2156.   staticpro (&Qbufferp);
  2157.   staticpro (&Qvectorp);
  2158.   staticpro (&Qchar_or_string_p);
  2159.   staticpro (&Qmarkerp);
  2160.   staticpro (&Qbuffer_or_string_p);
  2161.   staticpro (&Qinteger_or_marker_p);
  2162. #ifdef LISP_FLOAT_TYPE
  2163.   staticpro (&Qfloatp);
  2164.   staticpro (&Qnumberp);
  2165.   staticpro (&Qnumber_or_marker_p);
  2166. #endif /* LISP_FLOAT_TYPE */
  2167.  
  2168.   staticpro (&Qboundp);
  2169.   staticpro (&Qfboundp);
  2170.   staticpro (&Qcdr);
  2171.  
  2172.   defsubr (&Seq);
  2173.   defsubr (&Snull);
  2174.   defsubr (&Slistp);
  2175.   defsubr (&Snlistp);
  2176.   defsubr (&Sconsp);
  2177.   defsubr (&Satom);
  2178.   defsubr (&Sintegerp);
  2179.   defsubr (&Sinteger_or_marker_p);
  2180.   defsubr (&Snumberp);
  2181.   defsubr (&Snumber_or_marker_p);
  2182. #ifdef LISP_FLOAT_TYPE
  2183.   defsubr (&Sfloatp);
  2184. #endif /* LISP_FLOAT_TYPE */
  2185.   defsubr (&Snatnump);
  2186.   defsubr (&Ssymbolp);
  2187.   defsubr (&Sstringp);
  2188.   defsubr (&Svectorp);
  2189.   defsubr (&Sarrayp);
  2190.   defsubr (&Ssequencep);
  2191.   defsubr (&Sbufferp);
  2192.   defsubr (&Smarkerp);
  2193.   defsubr (&Ssubrp);
  2194.   defsubr (&Sbyte_code_function_p);
  2195.   defsubr (&Schar_or_string_p);
  2196.   defsubr (&Scar);
  2197.   defsubr (&Scdr);
  2198.   defsubr (&Scar_safe);
  2199.   defsubr (&Scdr_safe);
  2200.   defsubr (&Ssetcar);
  2201.   defsubr (&Ssetcdr);
  2202.   defsubr (&Ssymbol_function);
  2203.   defsubr (&Sindirect_function);
  2204.   defsubr (&Ssymbol_plist);
  2205.   defsubr (&Ssymbol_name);
  2206.   defsubr (&Smakunbound);
  2207.   defsubr (&Sfmakunbound);
  2208.   defsubr (&Sboundp);
  2209.   defsubr (&Sfboundp);
  2210.   defsubr (&Sfset);
  2211.   defsubr (&Sdefalias);
  2212.   defsubr (&Sdefine_function);
  2213.   defsubr (&Ssetplist);
  2214.   defsubr (&Ssymbol_value);
  2215.   defsubr (&Sset);
  2216.   defsubr (&Sdefault_boundp);
  2217.   defsubr (&Sdefault_value);
  2218.   defsubr (&Sset_default);
  2219.   defsubr (&Ssetq_default);
  2220.   defsubr (&Smake_variable_buffer_local);
  2221.   defsubr (&Smake_local_variable);
  2222.   defsubr (&Skill_local_variable);
  2223.   defsubr (&Saref);
  2224.   defsubr (&Saset);
  2225.   defsubr (&Snumber_to_string);
  2226.   defsubr (&Sstring_to_number);
  2227.   defsubr (&Seqlsign);
  2228.   defsubr (&Slss);
  2229.   defsubr (&Sgtr);
  2230.   defsubr (&Sleq);
  2231.   defsubr (&Sgeq);
  2232.   defsubr (&Sneq);
  2233.   defsubr (&Szerop);
  2234.   defsubr (&Splus);
  2235.   defsubr (&Sminus);
  2236.   defsubr (&Stimes);
  2237.   defsubr (&Squo);
  2238.   defsubr (&Srem);
  2239.   defsubr (&Smax);
  2240.   defsubr (&Smin);
  2241.   defsubr (&Slogand);
  2242.   defsubr (&Slogior);
  2243.   defsubr (&Slogxor);
  2244.   defsubr (&Slsh);
  2245.   defsubr (&Sash);
  2246.   defsubr (&Sadd1);
  2247.   defsubr (&Ssub1);
  2248.   defsubr (&Slognot);
  2249. }
  2250.  
  2251. SIGTYPE
  2252. arith_error (signo)
  2253.      int signo;
  2254. {
  2255. #ifdef USG
  2256.   /* USG systems forget handlers when they are used;
  2257.      must reestablish each time */
  2258.   signal (signo, arith_error);
  2259. #endif /* USG */
  2260. #ifdef VMS
  2261.   /* VMS systems are like USG.  */
  2262.   signal (signo, arith_error);
  2263. #endif /* VMS */
  2264. #ifdef BSD4_1
  2265.   sigrelse (SIGFPE);
  2266. #else /* not BSD4_1 */
  2267. #ifdef WINDOWSNT
  2268.   DebPrint(("EMACS broken @ "__FILE__ ": %d\n", __LINE__));
  2269. #else /* !WINDOWSNT */
  2270.   sigsetmask (SIGEMPTYMASK);
  2271. #endif /* !WINDOWSNT */
  2272. #endif /* not BSD4_1 */
  2273.  
  2274.   Fsignal (Qarith_error, Qnil);
  2275. }
  2276.  
  2277. _VOID_
  2278. init_data ()
  2279. {
  2280.   /* Don't do this if just dumping out.
  2281.      We don't want to call `signal' in this case
  2282.      so that we don't have trouble with dumping
  2283.      signal-delivering routines in an inconsistent state.  */
  2284. #ifndef CANNOT_DUMP
  2285.   if (!initialized)
  2286.     return;
  2287. #endif /* CANNOT_DUMP */
  2288. #ifndef WINDOWSNT
  2289.   signal (SIGFPE, arith_error);
  2290. #endif /* !WINDOWSNT */
  2291. #ifdef uts
  2292.   signal (SIGEMT, arith_error);
  2293. #endif /* uts */
  2294. }
  2295.